package cn.code.mycloud.module.system.dal.mysql.grid;

import java.util.*;

import cn.code.mycloud.framework.common.pojo.PageResult;
import cn.code.mycloud.framework.mybatis.core.query.LambdaQueryWrapperX;
import cn.code.mycloud.framework.mybatis.core.mapper.BaseMapperX;
import cn.code.mycloud.module.system.dal.dataobject.grid.GridDO;
import org.apache.ibatis.annotations.Mapper;
import cn.code.mycloud.module.system.controller.admin.grid.vo.*;

/**
 * 网格 Mapper
 *
 * @author 超级管理员
 */
@Mapper
public interface GridMapper extends BaseMapperX<GridDO> {

    default PageResult<GridDO> selectPage(GridPageReqVO reqVO) {
        return selectPage(reqVO, new LambdaQueryWrapperX<GridDO>()
                .likeIfPresent(GridDO::getName, reqVO.getName())
                .betweenIfPresent(GridDO::getCreateTime, reqVO.getCreateTime())
                .eqIfPresent(GridDO::getProvinceId, reqVO.getProvinceId())
                .likeIfPresent(GridDO::getProvinceName, reqVO.getProvinceName())
                .eqIfPresent(GridDO::getCityId, reqVO.getCityId())
                .likeIfPresent(GridDO::getCityName, reqVO.getCityName())
                .orderByDesc(GridDO::getId));
    }

}